/*
Script: App.js

/* Tracking */
var gService = false;
var gTimeZone = 1;
// Code section for Enable First-Party Cookie Tracking
function dcsCookie(){
	if (typeof(dcsOther)=="function"){
		dcsOther();
	}
	else if (typeof(dcsPlugin)=="function"){
		dcsPlugin();
	}
	else if (typeof(dcsFPC)=="function"){
		dcsFPC(gTimeZone);
	}
}
function dcsGetCookie(name){
	var cookies=document.cookie.split("; ");
	var cmatch=[];
	var idx=0;
	var i=0;
	var namelen=name.length;
	var clen=cookies.length;
	for (i=0;i<clen;i++){
		var c=cookies[i];
		if ((c.substring(0,namelen+1))==(name+"=")){
			cmatch[idx++]=c;
		}
	}
	var cmatchCount=cmatch.length;
	if (cmatchCount>0){
		idx=0;
		if ((cmatchCount>1)&&(typeof(gFpc)!="undefined")&&(name==gFpc)){
			var dLatest=new Date(0);
			for (i=0;i<cmatchCount;i++){
				var lv=parseInt(dcsGetCrumb(cmatch[i],"lv"));
				var dLst=new Date(lv);
				if (dLst>dLatest){
					dLatest.setTime(dLst.getTime());
					idx=i;
				}
			}
		}
		return unescape(cmatch[idx].substring(namelen+1));
	}
	else{
		return null;
	}
}
function dcsGetCrumb(cval,crumb){
	var aCookie=cval.split(":");
	for (var i=0;i<aCookie.length;i++){
		var aCrumb=aCookie[i].split("=");
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
function dcsGetIdCrumb(cval,crumb){
	var id=cval.substring(0,cval.indexOf(":lv="));
	var aCrumb=id.split("=");
	for (var i=0;i<aCrumb.length;i++){
		if (crumb==aCrumb[0]){
			return aCrumb[1];
		}
	}
	return null;
}
function dcsIsFpcSet(name,id,lv,ss){
	var c=dcsGetCookie(name);
	if (c){
		return ((id==dcsGetIdCrumb(c,"id"))&&(lv==dcsGetCrumb(c,"lv"))&&(ss=dcsGetCrumb(c,"ss")))?0:3;
	}
	return 2;
}
function dcsFPC(offset){
	if (typeof(offset)=="undefined"){
		return;
	}
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var name=gFpc;
	var dCur=new Date();
	var adj=(dCur.getTimezoneOffset()*60000)+(offset*3600000);
	dCur.setTime(dCur.getTime()+adj);
	var dExp=new Date(dCur.getTime()+315360000000);
	var dSes=new Date(dCur.getTime());
	WT.co_f=WT.vt_sid=WT.vt_f=WT.vt_f_a=WT.vt_f_s=WT.vt_f_d=WT.vt_f_tlh=WT.vt_f_tlv="";
	if (document.cookie.indexOf(name+"=")==-1){
		if ((typeof(gWtId)!="undefined")&&(gWtId!="")){
			WT.co_f=gWtId;
		}
		else if ((typeof(gTempWtId)!="undefined")&&(gTempWtId!="")){
			WT.co_f=gTempWtId;
			WT.vt_f="1";
		}
		else{
			WT.co_f="2";
			var cur=dCur.getTime().toString();
			for (var i=2;i<=(32-cur.length);i++){
				WT.co_f+=Math.floor(Math.random()*16.0).toString(16);
			}
			WT.co_f+=cur;
			WT.vt_f="1";
		}
		if (typeof(gWtAccountRollup)=="undefined"){
			WT.vt_f_a="1";
		}
		WT.vt_f_s=WT.vt_f_d="1";
		WT.vt_f_tlh=WT.vt_f_tlv="0";
	}
	else{
		var c=dcsGetCookie(name);
		var id=dcsGetIdCrumb(c,"id");
		var lv=parseInt(dcsGetCrumb(c,"lv"));
		var ss=parseInt(dcsGetCrumb(c,"ss"));
		if ((id==null)||(id=="null")||isNaN(lv)||isNaN(ss)){
			return;
		}
		WT.co_f=id;
		var dLst=new Date(lv);
		WT.vt_f_tlh=Math.floor((dLst.getTime()-adj)/1000);
		dSes.setTime(ss);
		if ((dCur.getTime()>(dLst.getTime()+1800000))||(dCur.getTime()>(dSes.getTime()+28800000))){
			WT.vt_f_tlv=Math.floor((dSes.getTime()-adj)/1000);
			dSes.setTime(dCur.getTime());
			WT.vt_f_s="1";
		}
		if ((dCur.getDay()!=dLst.getDay())||(dCur.getMonth()!=dLst.getMonth())||(dCur.getYear()!=dLst.getYear())){
			WT.vt_f_d="1";
		}
	}
	WT.co_f=escape(WT.co_f);
	WT.vt_sid=WT.co_f+"."+(dSes.getTime()-adj);
	var expiry="; expires="+dExp.toGMTString();
	var cur=dCur.getTime().toString();
	var ses=dSes.getTime().toString();
	document.cookie=name+"="+"id="+WT.co_f+":lv="+cur+":ss="+ses+expiry+"; path=/"+(((typeof(gFpcDom)!="undefined")&&(gFpcDom!=""))?("; domain="+gFpcDom):(""));
	var rc=dcsIsFpcSet(name,WT.co_f,cur,ses);
	if (rc!=0){
		WT.co_f=WT.vt_sid=WT.vt_f_s=WT.vt_f_d=WT.vt_f_tlh=WT.vt_f_tlv="";
		WT.vt_f=WT.vt_f_a=rc;
	}
}

// Code section for Use the new first-party cookie generated with this tag.
var gFpc="WT_FPC";
var gConvert=true;

// Code section for Set the First-Party Cookie domain
var gFpcDom=".sedus.de";

function dcsAdv(){
	dcsFunc("dcsET");
	dcsFunc("dcsCookie");
	dcsFunc("dcsAdSearch");
	dcsFunc("dcsTP");
}
var gDomain="webtrends.straight.de";
var gDcsId="dcs19ocvl10000w4d6kd9w9a3_7n6p";


if ((typeof(gConvert)!="undefined")&&gConvert&&(document.cookie.indexOf(gFpc+"=")==-1)&&(document.cookie.indexOf("WTLOPTOUT=")==-1)){
	document.write("<SCR"+"IPT TYPE='text/javascript' SRC='"+"http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+"/"+gDcsId+"/wtid.js"+"'><\/SCR"+"IPT>");
}
var gImages=new Array;
var gIndex=0;
var DCS=new Object();
var WT=new Object();
var DCSext=new Object();
var gQP=new Array();
var gI18n=false;
if (window.RegExp){
	var RE=gI18n?{"%25":/\%/g}:{"%09":/\t/g,"%20":/ /g,"%23":/\#/g,"%26":/\&/g,"%2B":/\+/g,"%3F":/\?/g,"%5C":/\\/g,"%22":/\"/g,"%7F":/\x7F/g,"%A0":/\xA0/g};
	if (gI18n){
		var EXRE=/dcs(uri)|(ref)|(aut)|(met)|(sta)|(sip)|(pro)|(byt)|(dat)|(p3p)|(cfg)|(redirect)|(cip)/i;
	}
}

// Add customizations here

function dcsVar(){
	var dCurrent=new Date();
	WT.tz=dCurrent.getTimezoneOffset()/60*-1;
	if (WT.tz==0){
		WT.tz="0";
	}
	WT.bh=dCurrent.getHours();
	WT.ul=navigator.appName=="Netscape"?navigator.language:navigator.userLanguage;
	if (typeof(screen)=="object"){
		WT.cd=navigator.appName=="Netscape"?screen.pixelDepth:screen.colorDepth;
		WT.sr=screen.width+"x"+screen.height;
	}
	if (typeof(navigator.javaEnabled())=="boolean"){
		WT.jo=navigator.javaEnabled()?"Yes":"No";
	}
	if (document.title){
		if (window.RegExp){
			var tire=new RegExp("^"+window.location.protocol+"//"+window.location.hostname+"\\s-\\s");
			WT.ti=document.title.replace(tire,"");
		}
		else{
			WT.ti=document.title;
		}
	}
	WT.js="Yes";
	WT.jv=dcsJV();
	if (document.body&&document.body.addBehavior){
		document.body.addBehavior("#default#clientCaps");
		WT.ct=document.body.connectionType||"unknown";
		document.body.addBehavior("#default#homePage");
		WT.hp=document.body.isHomePage(location.href)?"1":"0";
	}
	else{
		WT.ct="unknown";
	}
	if (document.all){
		WT.bs=document.body?document.body.offsetWidth+"x"+document.body.offsetHeight:"unknown";
	}
	else{
		WT.bs=window.innerWidth+"x"+window.innerHeight;
	}
	WT.fi="No";
	if (window.ActiveXObject){
		for(var i=10;i>0;i--){
			try{
				var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);
				WT.fi="Yes";
				WT.fv=i+".0";
				break;
			}
			catch(e){
			}
		}
	}
	else if (navigator.plugins&&navigator.plugins.length){
		for (var i=0;i<navigator.plugins.length;i++){
			if (navigator.plugins[i].name.indexOf('Shockwave Flash')!=-1){
				WT.fi="Yes";
				WT.fv=navigator.plugins[i].description.split(" ")[2];
				break;
			}
		}
	}
	if (gI18n){
		if (typeof(document.defaultCharset)=="string"){
			WT.le=document.defaultCharset;
		}
		else if (typeof(document.characterSet)=="string"){
			WT.le=document.characterSet;
		}
		else{
			WT.le="unknown";
		}
	}
	WT.tv="8.0.3";
	WT.sp="@@SPLITVALUE@@";
	DCS.dcsdat=dCurrent.getTime();
	DCS.dcssip=window.location.hostname;
	DCS.dcsuri=window.location.pathname;
	if (window.location.search){
		DCS.dcsqry=window.location.search;
		if (gQP.length>0){
			for (var i=0;i<gQP.length;i++){
				var pos=DCS.dcsqry.indexOf(gQP[i]);
				if (pos!=-1){
					var front=DCS.dcsqry.substring(0,pos);
					var end=DCS.dcsqry.substring(pos+gQP[i].length,DCS.dcsqry.length);
					DCS.dcsqry=front+end;
				}
			}
		}
	}
	if ((window.document.referrer!="")&&(window.document.referrer!="-")){
		if (!(navigator.appName=="Microsoft Internet Explorer"&&parseInt(navigator.appVersion)<4)){
			DCS.dcsref=window.document.referrer;
		}
	}
}

function dcsA(N,V){
	if (gI18n&&!EXRE.test(N)){
		if (N=="dcsqry"){
			var newV="";
			var params=V.substring(1).split("&");
			for (var i=0;i<params.length;i++){
				var pair=params[i];
				var pos=pair.indexOf("=");
				if (pos!=-1){
					var key=pair.substring(0,pos);
					var val=pair.substring(pos+1);
					if (i!=0){
						newV+="&";
					}
					newV+=key+"="+dcsEncode(val);
				}
			}
			V=V.substring(0,1)+newV;
		}
		else{
			V=dcsEncode(V);
		}
	}
	return "&"+N+"="+dcsEscape(V, RE);
}

function dcsEscape(S, REL){
	if (typeof(REL)!="undefined"){
		S=S.toString();
		for (var R in REL){
			S=S.replace(REL[R],R);
		}
		return S;
	}
	else{
		return escape(S);
	}
}

function dcsEncode(S){
	return (typeof(encodeURIComponent)=="function")?encodeURIComponent(S):escape(S);
}

function dcsCreateImage(dcsSrc){
	if (document.images){
		gImages[gIndex]=new Image;
		gImages[gIndex].src=dcsSrc;
		gIndex++;
	}
	else{
		document.write('<IMG ALT="" BORDER="0" NAME="DCSIMG" WIDTH="1" HEIGHT="1" SRC="'+dcsSrc+'">');
	}
}

function dcsMeta(){
	var elems;
	if (document.all){
		elems=document.all.tags("meta");
	}
	else if (document.documentElement){
		elems=document.getElementsByTagName("meta");
	}
	if (typeof(elems)!="undefined"){
		var length=elems.length;
		for (var i=0;i<length;i++){
			var name=elems.item(i).name;
			var content=elems.item(i).content;
			var equiv=elems.item(i).httpEquiv;
			if (name.length>0){
				if (name.indexOf("WT.")==0){
					WT[name.substring(3)]=content;
				}
				else if (name.indexOf("DCSext.")==0){
					DCSext[name.substring(7)]=content;
				}
				else if (name.indexOf("DCS.")==0){
					DCS[name.substring(4)]=content;
				}
			}
		}
	}
}

function dcsTag(){
	if (document.cookie.indexOf("WTLOPTOUT=")!=-1){
		return;
	}
	var P="http"+(window.location.protocol.indexOf('https:')==0?'s':'')+"://"+gDomain+(gDcsId==""?'':'/'+gDcsId)+"/dcs.gif?";
	if (gI18n){
		WT.dep="";
	}
	for (var N in DCS){
		if (DCS[N]){
			P+=dcsA(N,DCS[N]);
		}
	}
	var keys=["co_f","vt_sid","vt_f_tlv"];
	for (var i=0;i<keys.length;i++){
		var key=keys[i];
		if (WT[key]){
			P+=dcsA("WT."+key,WT[key]);
			delete WT[key];
		}
	}
	for (N in WT){
		if (WT[N]){
			P+=dcsA("WT."+N,WT[N]);
		}
	}
	for (N in DCSext){
		if (DCSext[N]){
			if (gI18n){
				WT.dep=(WT.dep.length==0)?N:(WT.dep+";"+N);
			}
			P+=dcsA(N,DCSext[N]);
		}
	}
	if (gI18n&&(WT.dep.length>0)){
		P+=dcsA("WT.dep",WT.dep);
	}
	if (P.length>2048&&navigator.userAgent.indexOf('MSIE')>=0){
		P=P.substring(0,2040)+"&WT.tu=1";
	}
	dcsCreateImage(P);
}

function dcsJV(){
	var agt=navigator.userAgent.toLowerCase();
	var major=parseInt(navigator.appVersion);
	var mac=(agt.indexOf("mac")!=-1);
	var ff=(agt.indexOf("firefox")!=-1);
	var ff0=(agt.indexOf("firefox/0.")!=-1);
	var ff10=(agt.indexOf("firefox/1.0")!=-1);
	var ff15=(agt.indexOf("firefox/1.5")!=-1);
	var ff2up=(ff&&!ff0&&!ff10&!ff15);
	var nn=(!ff&&(agt.indexOf("mozilla")!=-1)&&(agt.indexOf("compatible")==-1));
	var nn4=(nn&&(major==4));
	var nn6up=(nn&&(major>=5));
	var ie=((agt.indexOf("msie")!=-1)&&(agt.indexOf("opera")==-1));
	var ie4=(ie&&(major==4)&&(agt.indexOf("msie 4")!=-1));
	var ie5up=(ie&&!ie4);
	var op=(agt.indexOf("opera")!=-1);
	var op5=(agt.indexOf("opera 5")!=-1||agt.indexOf("opera/5")!=-1);
	var op6=(agt.indexOf("opera 6")!=-1||agt.indexOf("opera/6")!=-1);
	var op7up=(op&&!op5&&!op6);
	var jv="1.1";
	if (ff2up){
		jv="1.7";
	}
	else if (ff15){
		jv="1.6";
	}
	else if (ff0||ff10||nn6up||op7up){
		jv="1.5";
	}
	else if ((mac&&ie5up)||op6){
		jv="1.4";
	}
	else if (ie5up||nn4||op5){
		jv="1.3";
	}
	else if (ie4){
		jv="1.2";
	}
	return jv;
}

function dcsFunc(func){
	if (typeof(window[func])=="function"){
		window[func]();
	}
}








/* Tracking Ende (Aufrufe in initMain()) */









/*
Section: Event Extensions
*/

/*
Add new events "wheelup" and "wheeldown" to capture mouse wheel events
*/
Element.Events.extend({
	'wheelup': {
		type: Element.Events.mousewheel.type,
		map: function(event){
			event = new Event(event);
			if (event.wheel >= 0) this.fireEvent('wheelup', event)
		}
	},
	'wheeldown': {
		type: Element.Events.mousewheel.type,
		map: function(event){
			event = new Event(event);
			if (event.wheel <= 0) this.fireEvent('wheeldown', event)
		}
	}
});

/*
Section: Element Extensions
*/

/*
Property: getCoords
	return element coordinates as provided by <getCoordinates()> but with care of base (<myPage>) element coordinates
*/
Element.extend({
	getCoords: function(){
		var coords = this.getCoordinates();
		var pCoords = $('myPage').getCoordinates();
		coords.top = coords.top - pCoords.top;
		coords.left = coords.left - pCoords.left;
		return coords;
	}
});

/*
Property: handleProperties
	handle element properties by class names
*/
Element.extend({
	handleProperties: function(){
		if(this.hasClass('drag')){
			this.mkDraggable();
		}
		if(this.hasClass('tc')){
			if(document.getElementById('tc')){
				var tc = $('tc');
			}
			else{
				var tc = new Element('div', {
					'id':'tc'
				});
				['level1', 'level2', 'level3'].each(function(tcClass){
					tc.adopt(new Element('div', {
						'class':tcClass
					}));
				});
				myPage.adopt(tc);
			}
			if(this.hasClass('level1')){
				var myTc = tc.getElement('div.level1');
			}
			if(this.hasClass('level2')){
				var myTc = tc.getElement('div.level2');
			}
			if(this.hasClass('level3')){
				var myTc = tc.getElement('div.level3');
			}
			myTc.setHTML(this.innerHTML);
			myTc.setStyle('display','block');
			if(this.getElement('div.expand') != null){
				myTc.mkExpandable();
			}
			this.remove();
		}
		if(this.hasClass('scrollable'))
			this.mkScrollable();
		if(this.hasClass('saveable'))
			this.mkSaveable();
		if(this.hasClass('dropout'))
			this.dropout();
		if(this.hasClass('imggatter'))
			mkGatterEffectImg(this);
		if(this.hasClass('mkdrop')){
			this.setStyle('height', this.getSize().size.y - 6);
			addScrollToggler(this);
		}
	}
});

/*
Property: snapToGrid
	snap the element to the grid

Arguments:
	grid - the grid size in px, defaults to 100
*/
Element.extend({
	snapToGrid: function(grid){
		if(grid == undefined){
			var grid = gridSize;
		}
		this.effects({duration:250}).start({
			'top': Math.round(this.getTop()/grid)*grid,
			'left': Math.round(this.getLeft()/grid)*grid
		});
	}
});

/*
Property: mkSaveable
	make element saveable in "My Sedus" section
*/
Element.extend({
	mkSaveable: function(){
		if(this.id != null){
			var sid = this.id;
			var myBtn = new Element('div', {
				'class':'saveBtn',
				'events':{
					'click':function(e){
						e = new Event(e).stop();
						if(!sedusSaved.hasKey(sid)){
							sedusSaved.set(sid, new Date());
							this.empty();
							this.adopt(new Asset.image(imgPath + 'diskette-inaktiv.gif'));
							if(document.getElementById('se_de_teaser_my-sedus')){
								$('se_de_teaser_my-sedus').getElement('div.inner').highlight();
							}
						}
					}
				}
			});
			if(!sedusSaved.hasKey(sid)){
				//ray jiang myBtn.adopt(new Asset.image(imgPath + 'diskette.gif'));
			}
			else{
				//ray jiang myBtn.adopt(new Asset.image(imgPath + 'diskette-inaktiv.gif'));
			}
			if(this.getElement('div.drag_overlay') != null){
				myBtn.setStyle('top', 3);
				this.getElement('div.drag_overlay').adopt(myBtn);
			}
			else{
				this.adopt(myBtn);
			}
		}
	}
});

function scrollSlideDown(slide){
	slide.set(slide.step + 10);
}

function scrollSlideUp(slide){
	slide.set(slide.step - 10);
}

var tickSlide;

/*
Property: mkScrollable
	make element scrollable by mouse wheel or by using a fancy scrollbar generated by this extension
*/
Element.extend({
	mkScrollable: function(){
		var myInner = this.getElement('div.inner');
		if(myInner != null){
			var myInnerS = myInner.getSize();
			if(myInnerS.scrollSize.y > myInnerS.size.y){
				var scrollCont = new Element('div', {
					'class':'scrollcontent',
					'styles':{
						'float':'left',
						'clear':'none',
						'overflow':'hidden',
						'width':myInnerS.size.x - 12
					}
				});
				myInner.getChildren().each(function(el){
					if(!el.hasClass('dragger'))
						scrollCont.adopt(el);
				});
				myInner.adopt(scrollCont);
				scrollCont.setStyle('height', myInnerS.size.y - (scrollCont.getCoordinates().top - this.getCoordinates().top));
				var scrollContS = scrollCont.getSize();
				var myScrollBar = new Element('div', {
					'class':'noprint',
					'styles':{
						'position':'absolute',
						'right':0,
						'top':scrollCont.getCoordinates().top - this.getCoordinates().top,
						'width':11,
						'height': scrollContS.size.y,
						'background-color':'#f4f4f4'
					}
				});
				myInner.adopt(myScrollBar);
				var myInnerBar = new Element('div', {
					'styles':{
						'position':'absolute',
						'left':0,
						'top':10,
						'border-left':'1px solid #9F9F9F',
						'width':11,
						'height': myScrollBar.getSize().size.y - 20
					}
				});
				myScrollBar.adopt(myInnerBar);
				var myInnerBarS = myInnerBar.getSize();
				var myScroller = new Element('div', {
					'styles':{
						'position':'absolute',
						'left':1,
						'cursor':'pointer',
						'width':7,
						'height': Math.floor((myInnerBarS.size.y * myInnerBarS.size.y)/scrollContS.scrollSize.y) - 4,
						'background':'#9F9F9F'
					}
				});
				myInnerBar.adopt(myScroller);
				var mySlide = new Slider(myInnerBar, myScroller, {
					'steps': scrollContS.scrollSize.y - scrollContS.size.y,
					'mode': 'vertical',
					'onChange': function(step){
						scrollCont.scrollTo(0, step);
					}
				}).set(0);
				var aktiv;
				var myTopBtn = new Element('div', {
					'styles':{
						'position':'absolute',
						'left':0,
						'top':0,
						'width':11,
						'height': 10,
						'cursor':'pointer',
						'background-image':'url(\'' + imgPath + 'scroll-top-programmunfang.gif\')'
					},
					'events':{
						'mousedown':function(e){
							new Event(e).stop();
							tickSlide = mySlide;
							aktiv = setInterval("scrollSlideUp(tickSlide)", 100);
						},
						'mouseleave':function(e){
							new Event(e).stop();
							tickSlide = mySlide;
							clearInterval(aktiv);
						},
						'mouseup':function(e){
							new Event(e).stop();
							tickSlide = mySlide;
							clearInterval(aktiv);
						}
					}
				});
				myScrollBar.adopt(myTopBtn);
				var myBtmBtn = new Element('div', {
					'styles':{
						'position':'absolute',
						'bottom':0,
						'left':0,
						'width':11,
						'height': 10,
						'cursor':'pointer',
						'background-image':'url(\'' + imgPath + 'scroll-down-programmunfang.gif\')'
					},
					'events':{
						'mousedown':function(e){
							new Event(e).stop();
							tickSlide = mySlide;
							aktiv = setInterval("scrollSlideDown(tickSlide)", 100);
						},
						'mouseleave':function(e){
							new Event(e).stop();
							tickSlide = mySlide;
							clearInterval(aktiv);
						},
						'mouseup':function(e){
							new Event(e).stop();
							tickSlide = mySlide;
							clearInterval(aktiv);
						}
					}
				});
				myScrollBar.adopt(myBtmBtn);
				scrollCont.addEvents({
					'wheelup':function(e){
						new Event(e).stop();
						mySlide.set(this.getSize().scroll.y - 20);
					},
					'wheeldown':function(e){
						new Event(e).stop();
						mySlide.set(this.getSize().scroll.y + 20);
					}
				});
			}
		}
	}
});

/*
Property: moveTo
	move element to grid position

Arguments:
	x - distance from left border in <gridSize>
	y - distance from top border in <gridSize>
*/
Element.extend({
	moveTo: function(x, y){
		this.effects({
			duration:750,
			transition: Fx.Transitions['Back']['easeOut']
		}).start({
			'left': x * gridSize,
			'top': y * gridSize
		});
	}
});

/*
Property: mkExpandable
	make element expandable as used by tag clouds
*/
Element.extend({
	mkExpandable: function(){
		var myExp = this.getElement('div.expand');
		var me = this;
		if(myExp){
			var myToggler = new Element('div', {
				'class': 'tcToggler'
			});
			var myFx = myExp.effects({duration:250});
			var myToggleLink = new Element('span', {
				'class':'toggle',
				'styles':{
					'cursor':'pointer'
				},
				'events': {
					'click': function(e){
						new Event(e).stop();
						var myS = myExp.getSize();
						if(myS.size.y < myS.scrollSize.y){
							myFx.start({
								'height': myS.scrollSize.y
							});
							this.parentNode.parentNode.parentNode.getChildren().each(function(el){
								if(el != this){
									var exp = el.getElement('div.expand');
									if(exp != null && exp.getSize().size.y > 1){
										exp.effects({duration:250}).start({'height':1});
										var tl = el.getElement('span.toggle');
										tl.getElement('img').remove();
										tl.adopt(new Asset.image(imgPath + 'aufklappen.png', {'width':12, 'height':7}));
									}
								}
							});
							myToggleLink.getElement('img').remove();
							myToggleLink.adopt(new Asset.image(imgPath + 'zuklappen.png', {'width':12, 'height':7}));
						}
						else{
							myFx.start({
								'height':1
							});
							myToggleLink.getElement('img').remove();
							myToggleLink.adopt(new Asset.image(imgPath + 'aufklappen.png', {'width':12, 'height':7}));
						}
					}
				}
			});
			myToggleLink.adopt(new Asset.image(imgPath + 'aufklappen.png', {'width':12, 'height':7}));
			myToggler.adopt(myToggleLink);
			this.adopt(myToggler);
		}
	}
});

/*
Property: appear
	fade element in

Arguments:
	time - the effect duration in milliseconds
*/
Element.extend({
	appear: function(time){
		if(this.hasClass('noappear')){
			this.setStyles({'opacity': 1, 'visibility': 'visible'});
		}
		else{
			if(time == undefined){
				time = 500;
			}
			this.effect('opacity', {duration: time}).start(0,1);
		}
	}
});

/*
Property: disappear
	fade element out

Arguments:
	time - the effect duration in milliseconds
*/
Element.extend({
	disappear: function(time){
		if(time == undefined){
			time = 500;
		}
		var el = this;
		this.effect('opacity', {
			duration: time,
			onComplete: function(){
				el.remove();
			}
		}).start(0);
	}
});

/*
Property: highlight
	get user attention by highlighting element

Arguments:
	time - effect duration
*/
Element.extend({
	highlight: function(time){
		if(time == undefined){
			time = 250;
		}
		var myColor = new Color(this.getStyle('background-color'));
		this.effect('background-color', {
			duration: time
		}).start(myColor.mix('#fff')).chain(function(){
			this.start(myColor);
		});
	}
});

/*
Property: dropout
	drop element out of <myPage> allowing browser scrollbar usage
*/
Element.extend({
	dropout: function(){
		var myCont = this;
		var myClone = this.clone(false);
		myClone.id = 'dropped_out';
		var myC = this.getCoordinates();
		var pageC = myPage.getCoordinates();
		var myS = this.getSize();
		this.setStyle('display', 'none');
		$$('body').adopt(myClone);
		this.getChildren().each(function(el){myClone.adopt(el);});
		myClone.setStyles({
			'position':'absolute',
			'top':Math.round(myC.top/gridSize) * gridSize + pageC.top,
			'left':Math.round(myC.left/gridSize) * gridSize + pageC.left,
			'z-index':20,
			'width':Math.round(myC.width/gridSize) * gridSize
		});
		myClone.effects({duration:750}).start({'height':myS.scrollSize.y, 'opacity':0.9});
		var dc = $('droptoggler');
		if(dc != null){
			var dcC = dc.getCoordinates();
			var dcClone = dc.clone(true);
//			dc.setStyle('display', 'none');
			dc.remove();
			dcClone.id = 'dropped_out_toggler';
			dcClone.getElement('div').addClass('open');
			dcClone.setStyles({
				'position':'absolute',
				'top':Math.round(dcC.top/gridSize) * gridSize + pageC.top,
				'left':Math.round(dcC.left/gridSize) * gridSize + pageC.left,
				'z-index':20,
				'width':Math.round(dcC.width/gridSize) * gridSize
			});
			$$('body').adopt(dcClone);
			var dcLink = dcClone.getElement('a');
			dcClone.effects({
				duration:750,
				onComplete:function(){
					dcLink.setHTML(sedusStrings.back + '&nbsp;<img align="baseline" width="12" height="7" name="aufklappen" src="' + imgPath + 'pfeil-zuklappen.png" />');
				}
			}).start({
				'top':Math.round(myC.top/gridSize) * gridSize + pageC.top + myS.scrollSize.y
			});
			dcLink.removeEvents();
			dcLink.addEvent('click', function(e){
				new Event(e).stop();
				var myCont = $E('div.mkdrop');
				$('dropped_out').getChildren().each(function(el){
					myCont.adopt(el);
				});
				myCont.setStyle('display', 'block');
//				$('droptoggler').setStyle('display', 'block');
				
				$('dropped_out').remove();
				$('dropped_out_toggler').remove();
				addScrollToggler(myCont);
			});
		}
	}
});

/*
Property: dropin
	drop element back into <myPage>, see also <dropout()>
*/
Element.extend({
	dropin: function(){
//		this.setAttribute('style', '');
//		myPage.adopt(this);
		myPage.adopt(dropCont);
		this.remove();
/*
		var toggler = this.getElement('a.toggle');
		var cont = this;
		if(toggler != null){
			toggler.setStyle('background-image', 'url(\'' + imgPath + 'pfeil-aufklappen.png\')');
			toggler.removeEvents();
			toggler.addEvent('click', function(e){
					e = new Event(e).stop();
					cont.dropout();
			});
		}
		var dc = $('droptoggler');
		if(dc != null){
			dc.setAttribute('style', '');
			$('myPage').adopt(dc);
			var dcLink = dc.getElement('a');
			var tTarget = this;
			dcLink.removeEvents();
			dcLink.addEvent('click', function(){
				tTarget.dropout();
			});
		}
		*/
	}
});

/*
Property: makeTagEffect
	mouse over zoom effect

Arguments:
	tSize - target size to zoom to
*/
Element.extend({
	makeTagEffect: function(tSize){
		if(tSize == undefined)
			tSize = 20;
		this.addEvent('mouseenter', function(e){
			new Event(e).stop();
			this.effects({duration: 250}).start({
				'font-size': tSize
			});
		});
		var fSize = this.getStyle('font-size');
		this.addEvent('mouseleave', function(e){
			new Event(e).stop();
			this.effects({duration: 250}).start({
				'font-size': fSize
			});
		});
	}
});

/*
Property: getGridSize
	get element dimensions in grid

Returns:
	hash with {left: a, top: b, width: c, height: d}
*/
Element.extend({
	getGridSize: function(){
		var dim = this.getCoords();
		return {
			'top': Math.round(dim.top/gridSize),
			'left': Math.round(dim.left/gridSize),
			'width': Math.round(dim.width/gridSize),
			'height': Math.round(dim.height/gridSize)
		};
	}
});

/*
Property: setToDefaultPos
	set element positions to standard

Returns:
	false on error
*/
Element.extend({
	setToDefaultPos: function(nofree){
		var myGS = this.getGridSize();
		if(elemPos.hasKey(this.id)){
			var free = checkPos({'left': elemPos.get(this.id)[0], 'top': elemPos.get(this.id)[1], 'width': myGS.width, 'height': myGS.height});
			if(free == true){
				if(!nofree)
					freePos(myGS);
				blockPos({'left': elemPos.get(this.id)[0], 'top': elemPos.get(this.id)[1], 'width': myGS.width, 'height': myGS.height}, this.id);
				this.setStyles({
					'left':(elemPos.get(this.id)[0] * gridSize) + 'px',
					'top':(elemPos.get(this.id)[1] * gridSize) + 'px'
				});
			}
			else{
				if(document.getElementById(free)){
					if($(document.getElementById(free)).setToDefaultPos()){
						return this.setToDefaultPos(nofree);
					}
					else{
						return false;
					}
				}
				else{
					return false;
				}
			}
		}
		else{
			this.snapToGrid();
			blockPos(myGS);
			return true;
		}
	}
});

/*
Property: setToCookiePos
	set element to position stored in Cookie
*/
Element.extend({
	setToCookiePos: function(nofree){
		var myGS = this.getGridSize();
		if(sedusPrefs.hasKey(this.id)){
			if(checkPos({'left': sedusPrefs.get(this.id)[0], 'top': sedusPrefs.get(this.id)[1], 'width': myGS.width, 'height': myGS.height})){
				if(!nofree)
					freePos(myGS);
				blockPos({'left': sedusPrefs.get(this.id)[0], 'top': sedusPrefs.get(this.id)[1], 'width': myGS.width, 'height': myGS.height}, this.id);
				this.setStyles({
					'left':(sedusPrefs.get(this.id)[0] * gridSize) + 'px',
					'top':(sedusPrefs.get(this.id)[1] * gridSize) + 'px'
				});
				return true;
			}
			else{
				return this.setToDefaultPos(nofree);
			}
		}
		else{
			return this.setToDefaultPos(nofree);
		}
	}
});

/*
Property: setPos
	set element position

Arguments:
	free - boolean, shall we mark our old position as free?
*/
Element.extend({
	goToPos: function(pos){
		var myGS = this.getGridSize();
//		console.debug(this.id + ' geht zu ' + [pos.left, pos.top]);

		blockPos({'top':pos.top, 'left':pos.left, 'width':myGS.width, 'height':myGS.height}, this.id);

		return this.setStyles({
			'top':pos.top * gridSize,
			'left':pos.left * gridSize
		});
	},
	setToActPos: function(){
		var myGS = this.getGridSize();

//		console.debug(this.id + ' auf aktuelle Position setzen');

		var actCheck = checkPos(myGS);

		if(actCheck == true){

//			console.debug(this.id + ' blockiert ' + [myGS.left, myGS.top]);

			return blockPos(myGS, this.id);
		}
		else{

//			console.debug(this.id + ' blockiert durch ' + actCheck);

			var blockingElem = $(actCheck);
			if(blockingElem != null){
				freePos(blockingElem.getGridSize());
				sedusPrefs.remove(blockingElem.id);
				blockingElem.setStyles({'top':null, 'left':null});
				blockingElem.setPos();
			}

			return blockPos(myGS, this.id);
		}
	},
	setPos: function(){
		var myGS = this.getGridSize();

//		console.debug(myGS);

		if(this.hasClass('savepos')){

//			console.debug(this.id + ' positionieren');

			if(sedusPrefs.hasKey(this.id)){

//				console.debug(this.id + ' gespeichert auf ' + sedusPrefs.get(this.id));

				var mySavedPos = {
					'top':sedusPrefs.get(this.id)[1],
					'left':sedusPrefs.get(this.id)[0],
					'width':myGS.width,
					'height':myGS.height
				};
				if(checkPos(mySavedPos) === true){

//					console.debug(this.id + ' geht zur gespeicherten Position ' + checkPos(mySavedPos));

					return this.goToPos(mySavedPos);
				}
				else{
//					console.debug(this.id + ' muss bleiben');

					return this.setToActPos();
				}

			}
			else{

//				console.debug(this.id + ' nicht gespeichert');
				return this.setToActPos();

			}
		}
		else{

//			console.debug(this.id + ' nicht speicherbar');
			return this.setToActPos();

		}
/*
		var myCheck;
			var myGS = this.getGridSize();
		if(this.hasClass('savepos') && this.id != undefined && sedusPrefs.hasKey(this.id)){
			var cPos = {
				'top':sedusPrefs.get(this.id)[1],
				'left':sedusPrefs.get(this.id)[0],
				'width':myGS.width,
				'height':myGS.height
			};
			myCheck = checkPos(cPos);
			if(myCheck === true){
				this.setStyles({
					'top':cPos.top * gridSize,
					'left':cPos.left * gridSize
				});
			}
			else{
				myCheck = checkPos(myGS);
				if(myCheck !== true){
					sedusPrefs.remove(myCheck);
					if(document.getElementById(myCheck)){
						$(myCheck).setStyles({'top':none, 'left':none});
						$(myCheck).setPos();
					}
				}
				return this.blockPos();
			}
		}
		else{
 				myCheck = checkPos(myGS);
				if(myCheck !== true){
					sedusPrefs.remove(myCheck);
					if(document.getElementById(myCheck)){
						$(myCheck).setStyles({'top':none, 'left':none});
						$(myCheck).setPos();
					}
				}

			return this.blockPos();
		}
*/
	}
});

/*
Property: blockPos
	block element position in <elemPos>
*/
Element.extend({
	blockPos: function(){
		if(this.id != null && this.id != undefined && this.id.length > 0){
			return blockPos(this.getGridSize(), this.id);
		}
		else{
			return blockPos(this.getGridSize());
		}
	}
});

/*
Property: mkDraggable
	make the element be draggable
*/
Element.extend({
	mkDraggable: function(){
	var inner = this.getElement('div.inner');
	inner.setStyle('z-index', 6);
	var iC = inner.getCoordinates();
	var sdw = new Element('div', {
		'class':'sdw',
		'styles':{
			'position':'absolute',
			'z-index':5,
			'width':iC.width,
			'height':iC.height,
			'top':2,
			'left':2
		}
	});
	sdw.adopt(new Element('div', {
		'styles':{
			'position':'absolute',
			'width':iC.width + 1,
			'height':iC.height + 1,
			'background':'#000',
			'opacity':0.15
		}
	}));
	sdw.adopt(new Element('div', {
		'styles':{
			'position':'absolute',
			'left':2,
			'top':2,
			'width':iC.width,
			'height':iC.height - 3,
			'background':'#000',
			'opacity':0.1
		}
	}));
	sdw.adopt(new Element('div', {
		'styles':{
			'position':'absolute',
			'left':2,
			'top':2,
			'width':iC.width - 3,
			'height':iC.height,
			'background':'#000',
			'opacity':0.1
		}
	}));
	sdw.adopt(new Element('div', {
		'styles':{
			'position':'absolute',
			'left':1,
			'top':1,
			'width':iC.width - 1,
			'height':iC.height - 1,
			'background':'#000',
			'opacity':0.2
		}
	}));
	this.adopt(sdw);
	/* clone dragger and adopt to box */

		mydragger = dragger.clone();
		mydragger.injectTop(this.getElement('div.inner'));
		mydragger.getElement('div.dragger_left').setStyle('width', (mydragger.getCoordinates().width - 16) + 'px');
		var myhandle = drag_overlay.clone();
		this.adopt(myhandle);
	/* make box draggable */
		var pCoords = $('myPage').getCoordinates();
		new Drag.Move(this, {
			handle: myhandle,
			limit: {x: [0, pCoords.width - this.getCoordinates().width], y:[0, pCoords.height - this.getCoordinates().height]},
			onStart: function(el){
				var myGS = el.getGridSize();
				dragElemPos = [myGS.left, myGS.top];
				el.setStyle('z-index', 10);
				el.setStyle('opacity', 0.5);
				dragHelper.setStyles({
					'top': (myGS.top * gridSize) + 'px',
					'left': (myGS.left * gridSize) + 'px',
					'width': (myGS.width * gridSize) + 'px',
					'height': (myGS.height * gridSize) + 'px',
					'display': 'block'
				});
			},
			onDrag: function(el){
				var myGS = el.getGridSize();
				freePos({
					'left': dragElemPos[0],
					'top': dragElemPos[1],
					'width': myGS.width,
					'height': myGS.height
				});
				dragHelper.setStyles({
					'top': (myGS.top * gridSize) + 'px',
					'left': (myGS.left * gridSize) + 'px'
				});
				var posCheck = checkPos(myGS);
				if((posCheck == true) || (posCheck == el.id)){
					dragHelper.removeClass('error');
				}
				else{
					if(!dragHelper.hasClass('error')){
						dragHelper.addClass('error');
					}
				}
			},
			onComplete: function(el){
				var dragHelper = $('drag_helper');
				dragHelper.removeClass('error');
				dragHelper.setStyle('display', 'none');
				var myGS = el.getGridSize();
				var posCheck = checkPos(myGS);
				if(posCheck == true || posCheck == el.id ){
					el.snapToGrid(gridSize);
					blockPos(myGS, el.id);
					el.setStyle('z-index', '5');
					el.setStyle('opacity', '1');
					if(el.hasClass('savepos')){
						if(el.id != undefined){
							sedusPrefs.set(el.id, [myGS.left, myGS.top]);
						}
					}
				}
				else{
					var back = 1;
					if(document.getElementById(posCheck)){
						var bElem = $(document.getElementById(posCheck));
						var oGS = bElem.getGridSize();
						if(bElem.hasClass('drag') && oGS.top == myGS.top && oGS.left == myGS.left && oGS.width == myGS.width && oGS.height == myGS.height){
							back = 0;
							blockPos({
								'left': dragElemPos[0],
								'top': dragElemPos[1],
								'width': myGS.width,
								'height': myGS.height
							}, bElem.id);
							if(bElem.hasClass('savepos')){
								if(bElem.id != undefined){
									sedusPrefs.set(bElem.id, [dragElemPos[0], dragElemPos[1]]);
								}
							}
							bElem.moveTo(dragElemPos[0], dragElemPos[1]);
							el.snapToGrid(gridSize);
							blockPos(myGS, el.id);
							el.setStyles({'z-index':5, 'opacity':1});
							if(el.hasClass('savepos')){
								if(el.id != undefined){
									sedusPrefs.set(el.id, [myGS.left, myGS.top]);
								}
							}
						}
					}
					if(back == 1){
						blockPos({
							'left': dragElemPos[0],
							'top': dragElemPos[1],
							'width': myGS.width,
							'height': myGS.height
						}, el.id);
						dragHelper.setStyle('display', 'none');
						new Fx.Styles(el, {
							duration: 750,
							wait: false,
							transition: Fx.Transitions['Back']['easeOut'],
							onComplete: function(){
								el.setStyle('z-index', '5');
							}
						}).start({
							'left': dragElemPos[0] * gridSize,
							'top': dragElemPos[1] * gridSize,
							'opacity': 1
						});
					}
				}
			}
		});
	}}
);

/*
Section: Helper Functions
*/

/*
Function: idToURL
	get a URL from an element id

Arguments:
	id - element id

Returns:
	absolute URL string
*/
function idToURL(id, type){
	if(type == undefined){
		if(!id.contains('.php'))
			type = '.html';
		else
			type = '';
	}
	else
		type = '.' + type;
	return '/' + id.replace(/_/g, '/') + type;
}

/*
Function: urlToId
	parse relative URL and return element id

Arguments:
	url - relative URL to box code

Returns:
	element id
*/
function urlToId(url){
	var id = url.replace(/\//g, '_');
	var ar = id.slice(1, id.length).split('.');
	if(ar[1].contains('php'))
		id = ar[0] + '.' + 'php';
	else
		id = ar[0];
	return id;
}

/*
Function: checkPos
	check if position is free, see also <posMatrix>, <blockPos()>, <setPos()>

Arguments:
	pos - position to check as object of {left: a, top: b, width: c, height: d}

Returns:
	true, 1 or id of blocking element
*/
function checkPos(pos){http://213.183.6.214/se/de/company/milestones.php
	for(var i = pos.left; i < (pos.left + pos.width); i++){
		for(var j = pos.top; j < (pos.top + pos.height); j++){
			if(posMatrix[i][j] != null){
				return posMatrix[i][j];
			}
		}
	}
	return true;
}

/*
Function: blockPos
	block position in <posMatrix>

Arguments:
	pos - position to check as object of {left: a, top: b, width: c, height: d}
	index - number 1 or the element id to block for
*/
function blockPos(pos, index){
	if(index == undefined){
		index = 0;
	}
	for(var i = pos.left; i < (pos.left + pos.width); i++){
		for(var j = pos.top; j < (pos.top + pos.height); j++){
			posMatrix[i][j] = index;
		}
	}
}

/*
Function: freePos
	free position in <posMatrix>
	See also: <blockPos()>, <checkPos()>

Arguments:
	pos - position to check as object of {left: a, top: b, width: c, height: d}
*/
function freePos(pos){
	for(var i = pos.left; i < (pos.left + pos.width); i++){
		for(var j = pos.top; j < (pos.top + pos.height); j++){
			posMatrix[i][j] = null;
		}
	}
}

/*
Function: OL_bind
	bind overlay target function to elem

Arguments:
	e - action event
*/
function OL_bind(e){
	e = new Event(e);
	e.preventDefault();
	this.blur();
	OL_show(this.href);
	this.onclick = OL_bind;
	return false;
}

function OL_inner_bind(e){
	e = new Event(e);
	e.preventDefault();
	this.blur();
	OL_change(this.href);
	this.onclick = OL_inner_bind;
	return false;
}

/*
Function: OL_bind_form
	bind overlay target function to form elem

Arguments:
	e - action event
*/
function OL_bind_form(e){
	var e = new Event(e);
	e.preventDefault();
	var myBG, myCont;
	if(!$('overlay_bg')){
		myBG = new Element('div', {
			'id':'overlay_bg',
			'styles':{
				'position':'absolute',
				'top':0,
				'left':0,
				'width':'100%',
				'height':'100%',
				'background-color':'#fff',
				'opacity':0,
				'visibility':'hidden',
				'z-index':100
			}
		});
		$$('body').adopt(myBG);
	}else{
		myBG = $('overlay_bg');
	}
	if(!$('overlay_inner')){
		var mPC = myPage.getCoordinates();
		myCont = new Element('div', {
			'id':'overlay_inner',
			'styles':{
				'position':'absolute',
				'top':mPC.top,
				'left':mPC.left,
				'width':mPC.width,
				'height':mPC.height,
				'display':'none',
				'z-index':110
			}
		});
		$$('body').adopt(myCont);
	}
	else{
		myCont = $('overlay_inner');
	}
	if(!$(this).getElement('ovl_f')){
		$(this).adopt(new Element('input', {
			'id':'ovl_f',
			'type':'hidden',
			'name':'overlay',
			'value':'1'
		}));
	}
	this.send({
		update: 'overlay_inner',
		evalScripts: true,
		onComplete:function(){OL_show();}
	});
	return false;
}

/*
Function: OL_hide
	hide overlay by effect
*/
function OL_hide(){
	if($('overlay_bg')){
		$('overlay_bg').effects({duration:750}).start({'opacity':0});
	}
	if($('overlay_inner')){
		var myLeft = myPage.getStyle('left');
		$('overlay_inner').effects({
			duration:500,
			onComplete:function(){
				//$('overlay_inner').setStyles({'display':'none', 'left':myLeft});
				$('overlay_inner').remove();
				var flash = $('flash');
	$ES('select').setStyle('visibility', 'visible');
				if (flash != null){
					$('flash').setStyle('display', 'block');
				}
			}
		}).start({'left':-1000});
	}
	window.onscroll = null;
}

/*
Function: OL_show
	show overlay by effect
	invoked by <OL_bind()> and <OL_bind_form()>

Arguments:
	url - URI to fetch content from with AJAX
*/
function OL_show(url){
	var myBG, myCont;
	if(!$('overlay_bg')){
		myBG = new Element('div', {
			'id':'overlay_bg',
			'styles':{
				'position':'absolute',
				'top':0,
				'left':0,
				'width':'100%',
				'height':'100%',
				'background-color':'#fff',
				'opacity':0,
				'visibility':'hidden',
				'z-index':100
			}
		});
		$$('body').adopt(myBG);
	}else{
		myBG = $('overlay_bg');
	}
	if(!$('overlay_inner')){
		var mPC = $('myPage').getCoordinates();
		myCont = new Element('div', {
			'id':'overlay_inner',
			'styles':{
				'position':'absolute',
				'top':mPC.top,
				'left':mPC.left,
				'width':mPC.width,
				'height':mPC.height,
				'visibility':'hidden',
				'z-index':110
			}
		});
		$$('body').adopt(myCont);
	}
	else{
		myCont = $('overlay_inner');
	}
	window.scrollTo(0,0);
	window.onscroll = function(){
		window.scrollTo(0,0);
	}
	var flash = $('flash');
	$ES('select').setStyle('visibility', 'hidden');
	if (flash != null){
		$('flash').setStyle('display', 'none');
	}
	myBG.effects({duration:750}).start({'opacity':[0, 0.9]});
	if(url != undefined){
		var myReq = new Ajax(url, {
			update: myCont,
			data:'overlay=1',
			onComplete:function(){
				var myLeft = myPage.getCoordinates().left;
				myCont.setStyles({
					'left':-1000,
					'visibility':'visible'
				});
				myCont.effects({
					duration:750,
					onComplete: function(){
						myCont.getElements('div.scrollable').each(function(scroll){scroll.mkScrollable();});
						myCont.getElements('a.overlay').each(function(lnk){lnk.onclick=OL_inner_bind;});
					}
				}).start({
					'left': myLeft
				});
			},
			evalScripts: true
		}).request();
	}
	else{
		var myLeft = myPage.getCoordinates().left;
		myCont.setStyles({
			'left':-1000,
			'display':'block'
		});
		myCont.effects({
			duration:750
		}).start({
			'left':myLeft
		});
		myCont.getElements('div.scrollable').each(function(el){el.mkScrollable();});
	}
}

function OL_change(url){
	var myCont = $('overlay_inner');
	if(url != undefined){
/*		if(url.contains('?'))
			url += '&overlay';
		else
			url += '?overlay';*/
		var myLeft = myCont.getCoordinates().left;
		var flash = $('flash');
	$ES('select').setStyle('visibility', 'hidden');
		if (flash != null){
			$('flash').setStyle('display', 'none');
		}
		myCont.effects({
			duration:250,
			onComplete: function(){
				var myReq = new Ajax(url, {
					data: 'overlay=1',
					update: myCont,
					onComplete:function(){
						var myLeft = myPage.getCoordinates().left;
						myCont.setStyles({
							'left':-1000,
							'display':'block'
						});
						myCont.effects({
							duration:750,
							onComplete: function(){
								myCont.getElements('div.scrollable').each(function(scroll){scroll.mkScrollable();});
								myCont.getElements('a.overlay').each(function(lnk){lnk.onclick=OL_inner_bind;});
							}
						}).start({
							'left': myLeft
						});
					},
					evalScripts: true
				}).request();
			}
		}).start({
			'left': 0 - (myLeft + myCont.getCoordinates().width)
		});

	}
}

/*
Section: Base Functions
*/

/*
Function: setBoxes

Arguments:
	elemIds - array of element ids to set
*/
function setBoxes(elemIds){
	var eIds = $A(elemIds);
	$$('div.box, div.content').each(function(el){
		if(eIds.indexOf(el.id) == -1){
			freePos(el.getGridSize());
			el.disappear();
		}
	});
	for(var i = 0; i < eIds.length; i++){
		if(!$(eIds[i])){
			fetchNewBox(eIds[i]);
		}
	}
}

/*
Function: fetchNewBox

Arguments:
	id = box id (serialized URL), see also <urlToId()>
*/
function fetchNewBox(id){
	var clipper = new Element('div');
	new Ajax(idToURL(id), {
		method: 'get',
		update: clipper,
		onComplete: function(){
			clipper.getChildren().each(function(el){
				if(el.hasClass('tc')){
					el.remove();
/*					if(document.getElementById('tc')){
						var tc = $('tc');
					}
					else{
						var tc = new Element('div', {
							'id':'tc'
						});
						myPage.adopt(tc);
					}
					tc.adopt(el);
*/				}
				else{
					myPage.adopt(el);
					el.handleProperties();
					el.appear();
				}
			});
		}
	}).request();
}

/*
Function: fetchIndex

Arguments:
	url - url to fetch
*/
function fetchIndex(url){
	myFrame.removeEvents();
	myFrame.onload=function(){
		var boxIds = [];
		$A(this.contentWindow.document.getElementsByTagName('div')).each(function(el){
			boxIds.push(el.id);
		});
		setBoxes(boxIds);
	};
	$('index_field').value += 1;
	$('fetchform').action = url + '?index';
	$('fetchform').submit();
}

/*
Function: mkMagicImgSel
	make smoothy image gallery

Arguments:
	elem - container for all magic
*/
function mkMagicImgSel(elem){
	var thumb_cont = new Element('div', {
		'class': 'thumb_cont',
		'styles': {
			'height': 1,
			'opacity':0
		}
	});
	var myFx = elem.effects({duration: 500});
	var myToggleFx = thumb_cont.effects({duration: 250});
	elem.getElements('div.imglink').each(function(imglink){
		if(imglink.id){
			var changer = new Element('a', {
				'href': '#',
				'rel': 'static',
				'events': {
					'click': function(e){
						new Event(e).stop();
						savedPics.set(elem.parentNode.id, imglink.id);
						var myImg = new Asset.image(idToURL(imglink.id, 'jpg'), {
								'alt': '',
								'class': 'back',
								onload: function(){
									var myGS = elem.getGridSize();
									if(myImg.width > myImg.height && myGS.width < myGS.height){
										elem.effects({duration:750}).start({
											'height': 354,
											'width': 474
										});
											$(elem.parentNode).effects({duration:500}).start({
												'top': 120,
												'height': 360,
												'width': 480
											});
									}
									else{
										if(myImg.width < myImg.height && myGS.width > myGS.height){
											elem.effects({duration:500}).start({
												'height': 474,
												'width': 354
											});
											$(elem.parentNode).effects({duration:500}).start({
												'top': 0,
												'height': 480,
												'width': 360
											});
										}
									}
								}
						});
						myToggleFx.start({
							'height': 1,
							'opacity':0
						}).chain(function(){

	var overlay = new Element('div', {
		'styles': {
			'opacity': 0,
			'position': 'absolute',
			'left': 0,
			'top': 0,
			'height': '100%',
			'width': '100%',
			'background-image': 'url(\'' + imgPath + 'gatter.gif\')'
		}
	});
	elem.adopt(overlay);
	overlay.effects({
		duration:500,
		onComplete: function(){
			overlay.remove();
		}
	}).start({
		'opacity':1
	});

							myFx.start({
								'opacity': 0
							}).chain(function(){
								elem.getElement('img.back').remove();
								elem.adopt(myImg);
/*								this.set({
									'opacity': 1
								});
*/								this.start.delay(250, this, {'opacity': 1});
								fadeImgIn(myImg);
							});
						});
					}
				}
			});
			changer.adopt(new Asset.image(idToURL(imglink.id + '.thumb', 'jpg')));
			thumb_cont.adopt(changer);
		}
		imglink.remove();
	});
	elem.adopt(thumb_cont);
    var myScroll = new Scroller(thumb_cont, {area: 50, velocity: 0.5});
    thumb_cont.addEvent('mouseover', myScroll.start.bind(myScroll));
    thumb_cont.addEvent('mouseout', myScroll.stop.bind(myScroll));
	var toggler = new Element('div', {
		'class': 'toggler'
	});
	var myT = new Element('a', {
		'href': '#',
		'rel': 'static',
		'events': {
			'click': function(e){
				new Event(e).stop();
				if(thumb_cont.getCoordinates().height > 1){
					myToggleFx.start({'height': 1, 'opacity':0});
				}
				else{
					myToggleFx.start({'height': 150, 'opacity':1});
				}
			}
		}
	});
	toggler.adopt(myT);
	myT.adopt(new Asset.image(imgPath + 'toggler.png', {'alt': ''}));
	elem.adopt(toggler);
}

/*
Function: fadeImgIn
	fade image in with gatter effect

Arguments:
	img - the image element, should be in DOM already
*/
function fadeImgIn(img){
	var imgCoords = img.getCoordinates();
	var overlay = new Element('div', {
		'styles': {
			'position': 'absolute',
			'left': 0,
			'top': 0,
			'height': imgCoords.height,
			'width': imgCoords.width,
			'background-image': 'url(\'' + imgPath + 'gatter.gif\')'
		}
	});
	$(img.parentNode).adopt(overlay);
	img.effects({duration:5000}).start({
		'opacity':[0,1]
	});
	overlay.effects({
		duration:5000,
		onComplete: function(){
			overlay.remove();
		}
	}).start({
		'opacity':0
	});
}
function switchImg(cont, url){
	cont.getElement('img').src = url;
}
function mkProductImagePage(myCont, first){
	var myInner = myCont.getElement('div.inner');
	var myImgCont = myCont.getElement('div.imglink');
	var innerC = myInner.getCoords();
	myImgCont.setStyles({
		'width': innerC.width - 2,
		'height': innerC.height - 2,
		'border': '1px solid #9F9F9F',
		'overflow':'hidden'
	});
	myImgCont.adopt(new Asset.image(first));
}
function mkProductImageThumbs(myCont, tCont){
	myCont.getElements('div.product_thumb').each(function(el){
		el.getElement('a').addEvent('click', function(e){
			new Event(e).stop();
			switchImg(tCont, idToURL(el.id, 'jpg'));
		});
	});
}

function mkProductScroll(myCont){
	var products = myCont.getElements('div.product_box');
	var myGS = myCont.getGridSize();
	var myS = myCont.getSize();
	var a = myGS.width;
	var b = myGS.height;
	var pIndex = 0;
	var cWidth = a * b;
	if(myS.scrollSize.y > (myS.size.y + 10)){
		var cont;
		var myScroll = new Fx.Scroll(myCont, {
			duration: 1000,
			transition: Fx.Transitions.Quad.easeInOut
		});
		for(var i = 0; i <= Math.round(myS.scrollSize.y/myS.size.y); i++){
			var pGWidth = 0;
			cont = new Element('div', {
				'id': myCont.id + '-idx' + i,
				'class':'idx',
				'styles': {
					'position':'absolute',
					'top':0,
					'left': i * a * gridSize,
					'height': b * gridSize,
					'width': a * gridSize
				}
			});
			myCont.adopt(cont);
			if(pIndex > 0){
				var back = new Element('div', {
					'class':'noprint',
					'styles': {
						'font-weight':'bold',
						'color':'#fff',
						'position':'absolute',
						'bottom':6,
						'left':1,
						'height':21,
						'overflow':'hidden',
						'background-color':'#D84519',
						'line-height':21,
						'cursor':'pointer',
						'z-index':20
					},
					'events': {
						'click':function(e){
							new Event(e).stop();
							myScroll.scrollTo(myCont.getSize().scroll.x - a * gridSize, 0);
						}
					}
				});
				back.setHTML('<img width="13" height="11" style="margin:6px 5px 0 5px;" align="absmiddle" src="/se/global/layout/img/doppelpfeil_zurueck.png" />');
				cont.adopt(back);
			}
			for(var j = pIndex; j < products.length; j++){
				if(products[j].getGridSize().width + pGWidth <= cWidth){
					pGWidth += products[j].getGridSize().width;
					cont.adopt(products[j]);
					pIndex++;
				}
			}
			if(products.length > pIndex){
				var next = new Element('div', {
					'class':'noprint',
					'styles': {
						'font-weight':'bold',
						'color':'#fff',
						'position':'absolute',
						'bottom':6,
						'right':6,
						'height':21,
						'overflow':'hidden',
						'background-color':'#D84519',
						'line-height':21,
						'cursor':'pointer',
						'z-index':20
					},
					'events': {
						'click':function(e){
							new Event(e).stop();
							myScroll.scrollTo(a * gridSize + myCont.getSize().scroll.x, 0);
						}
					}
				});
				next.setHTML('<img style="margin:6px 4px 0 6px;" width="13" height="11" align="absmiddle" src="/se/global/layout/img/doppelpfeil_weiter.png" />');
				cont.adopt(next);
			}
		}
	}
}
function scrollUp(id){
	var myCont = $(document.getElementById(id));
	myCont.scrollTo(0, myCont.getSize().scroll.y - 20);
};


function scrollDown(id){
	var myCont = $(document.getElementById(id));
	if((myCont.getSize().scroll.y + 20) < (myCont.getSize().scrollSize.y - 6 - myCont.getSize().size.y))
		myCont.scrollTo(0, myCont.getSize().scroll.y + 20);
	else
		myCont.scrollTo(0, myCont.getSize().scrollSize.y - 6 - myCont.getSize().size.y);
};

/*
Function: mkProdDetailsScrollableDemo
	demo function for onmousedown scrolling
 */
function mkProdDetailsScrollableDemo(cont){
	var myCont = cont.getElement('div.inner');
	var aktiv = null;
	myCont.id = 'demoscroll';
	myCont.setStyle('z-index', 19);
	myCont.scrollTo(0, 0);
	myCont.addEvents({
		'wheelup':function(){scrollUp('demoscroll');},
		'wheeldown':function(){scrollDown('demoscroll');}
	});
	var myS = myCont.getSize();
	if((myS.scrollSize.y - 10) > myS.size.y){
				var back = new Element('div', {
					'class':'noprint',
					'styles': {
						'font-weight':'bold',
						'color':'#fff',
						'position':'absolute',
						'top':0,
						'right':6,
						'height':21,
						'overflow':'hidden',
						'background-color':'#D84519',
						'line-height':21,
						'cursor':'pointer',
						'text-align':'center',
						'z-index':20
					},
					'events': {
						'mousedown':function(e){
							new Event(e).stop();
							aktiv = setInterval("scrollUp('demoscroll')", 100);
						},
						'mouseup':function(e){
							new Event(e).stop();
							clearInterval(aktiv);
						},
						'mouseout':function(e){
							new Event(e).stop();
							if(aktiv)
								clearInterval(aktiv);
						}						
					}
				});
				back.setHTML('<img style="margin:8px 5px 0 5px;" width="12" height="7" align="absmiddle" src="/se/global/layout/img/pfeil-zuklappen.png" />');
				$(myCont.parentNode).adopt(back);
				var next = new Element('div', {
					'class':'noprint',
					'styles': {
						'font-weight':'bold',
						'color':'#fff',
						'position':'absolute',
						'bottom':6,
						'right':6,
						'height':21,
						'overflow':'hidden',
						'background-color':'#D84519',
						'line-height':21,
						'cursor':'pointer',
						'text-align':'center',
						'z-index':20
					},
					'events': {
						'mousedown':function(e){
							new Event(e).stop();
							aktiv = setInterval("scrollDown('demoscroll')", 100);
						},
						'mouseup':function(e){
							new Event(e).stop();
							clearInterval(aktiv);
						},
						'mouseout':function(e){
							new Event(e).stop();
							if(aktiv)
								clearInterval(aktiv);
						}
					}
				});
				next.setHTML('<img style="margin:8px 5px 0 5px;" width="12" height="7" align="absmiddle" src="/se/global/layout/img/pfeil-aufklappen.png" />');
				$(myCont.parentNode).adopt(next);
			}
}
/*
Function: mkProdDetailsScrollable

Arguments:
	cont - container to use
 */
function mkProdDetailsScrollable(cont){
	var myCont = cont.getElement('div.inner');
	myCont.scrollTo(0, 0);
	var myScroll = new Fx.Scroll(myCont, {
		duration: 1000,
		transition: Fx.Transitions.Quad.easeInOut
	});
	var myS = myCont.getSize();
	if(myS.scrollSize.y > myS.size.y + 10){
		for(var i = 0; i < Math.ceil(myS.scrollSize.y/(myS.size.y + 10)); i++){
				var back = new Element('div', {
					'class':'noprint',
					'styles': {
						'font-weight':'bold',
						'color':'#fff',
						'position':'absolute',
						'top':(i+1) * Math.round(myS.size.y/gridSize) * gridSize,
						'right':0,
						'height':21,
						'overflow':'hidden',
						'background-color':'#D84519',
						'line-height':21,
						'cursor':'pointer',
						'text-align':'center',
						'z-index':20
					},
					'events': {
						'click':function(e){
							new Event(e).stop();
							myScroll.scrollTo(0, Math.round((myCont.getSize().scroll.y - myS.size.y)/gridSize) * gridSize);
						}
					}
				});
				back.setHTML('<img style="margin:8px 5px 0 5px;" width="12" height="7" align="absmiddle" src="/se/global/layout/img/pfeil-zuklappen.png" />');
				myCont.adopt(back);
		}
		for(var i = 0; i < Math.ceil(myS.scrollSize.y/(myS.size.y + 10)); i++){
				var next = new Element('div', {
					'class':'noprint',
					'styles': {
						'font-weight':'bold',
						'color':'#fff',
						'position':'absolute',
						'top':i * Math.round(myS.size.y/gridSize) * gridSize - 26,
						'right':0,
						'height':21,
						'overflow':'hidden',
						'background-color':'#D84519',
						'line-height':21,
						'cursor':'pointer',
						'text-align':'center',
						'z-index':20
					},
					'events': {
						'click':function(e){
							new Event(e).stop();
							myScroll.scrollTo(0, Math.round((myCont.getSize().scroll.y + myS.size.y)/gridSize) * gridSize);
						}
					}
				});
				next.setHTML('<img style="margin:8px 5px 0 5px;" width="12" height="7" align="absmiddle" src="/se/global/layout/img/pfeil-aufklappen.png" />');
				myCont.adopt(next);
		}
	}
}
/*
Function: highlightLinks
	highlight all links whose href contains provided text

Arguments:
	text - string to search for
 */
function highlightLinks(text){
	if(text.contains('activation'))
		text = 'activation';
	if(text.contains('ambition'))
		text = 'ambition';
	$ES('#tc a[href]').each(function(link){
		if(link.getAttribute('href').contains(text))//str))
			link.addClass('highlight');
	});
}

function highlightMoreLinks(text){
	var myStr = text.split('-');
	$ES('#tc a[href]').each(function(link){
		myStr.each(function(str){
			if(link.getAttribute('href').contains(str))
				link.addClass('highlight');
		});
	});
}

/*
Function: mkGatterEffectImg
	makes fancy effect by using boxes with modified background-image-position to cut an oimage in pieces and let them "dance"

Arguments:
	myCont - element with image src as id, see also <urlToId()> and <idToURL()>
 */
function mkGatterEffectImg(myCont){
			var myImgURL = idToURL(myCont.getElement('div.imglink').id, 'jpg');
			var myS = myCont.getCoords();
			var time = 500;
			var i = 2;
			var elS;
			myCont.getElements('div.boxlike').each(function(el){
				elS = el.getCoords();
				elS.top = elS.top - myS.top;
				elS.left = elS.left - myS.left;
				if(navigator.appName.contains('Microsoft')){
					el.setStyles({
						'width': elS.width - 6,
						'height': elS.height - 6,
						'backgroundImage': 'url(' + myImgURL + ')',
						'backgroundPosition': (0 - elS.left) + 'px ' + (0 - elS.top) + 'px',
						'border': '1px solid #4d4d4d'
					});
				}
				else{
					el.setStyles({
						'width': elS.width - 8,
						'height': elS.height - 8,
						'backgroundImage': 'url(' + myImgURL + ')',
						'backgroundPosition': (0 - elS.left) + 'px ' + (0 - elS.top) + 'px',
						'border': '1px solid #4d4d4d'
					});
				}
				var myStyles = {};
				if(Math.round(Math.random()) == 1){
					el.setStyle('left', 0 - gridSize);
					if(Math.round(Math.random())){
						myStyles.left = elS.left;
					}
					else{
						myStyles.left = [myS.width, elS.left];
					}
				}
				else{
					el.setStyle('top', 0 - gridSize);
					if(Math.round(Math.random()) == 1){
						myStyles.top = elS.top;
					}
					else{
						myStyles.top = [myS.height, elS.top];
					}
				}
				var elFx = el.effects({
					duration:time,
					transition: Fx.Transitions['Back']['easeOut']
				});
				elFx.start({}).chain(function(){
					this.start.delay(++i * time + 200, this, myStyles);
				});
			});
}

/*
Function: printContainer
	opens popup window and injects innerHTML of requested container with print.css

Arguments:
	cont - container element
	desc - optional: print page heading
*/
function printContainer(cont, desc){
	var popup = window.open(null, 'Print', 'dependent=yes,scrollbars=yes,height=700,width=860,left=50,top=100,toolbar=no,status=no,menubar=no,resizable=yes,location=no');
	popup.document.open();
	popup.document.writeln('<?xml version="1.0" encoding="UTF-8"?>');
	popup.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
	popup.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">');
	popup.document.writeln('<head>');
	popup.document.writeln('<title>' + sedusStrings.print_prev + '</title>');
	popup.document.writeln('<meta http-equiv="content-type" content="text/html; charset=UTF-8" />');
	popup.document.writeln('<link href="/se/global/layout/css/style.css" rel="stylesheet" type="text/css" />');
	popup.document.writeln('<link href="/se/global/layout/css/content.css" rel="stylesheet" type="text/css" />');
	popup.document.writeln('<link href="/se/global/layout/css/print.css" rel="stylesheet" type="text/css" />');
	popup.document.writeln('</head>');
	popup.document.writeln('<body style="padding:1em 0; 0">');
//	popup.document.writeln('<div style="position:absolute; top:10px; left:10px;"><img style="float:left;" alt="Sedus" src="' + imgPath + 'sedus-logo.gif" /></div>');
	popup.document.writeln('<div><img style="float:left;" alt="Sedus" src="' + imgPath + 'sedus-logo.gif" /></div>');
//	popup.document.writeln('<div style="position:absolute;top:10px;right:20px;padding-bottom:50px;">');
//	popup.document.writeln('<a href="javascript:window.close();" style="font-weight:bold;color:#000;" rel="static"><img align="absmiddle" src="/se/global/layout/img/schliessen.png" width="15" height="14" alt="" />&nbsp;&nbsp;Schlie&#223;en</a>');
//	popup.document.writeln('</div>');
	if(desc != undefined){
		popup.document.writeln('<h1>' + desc + '</h1>');
	}
	var offset = 0;
//	popup.document.writeln('<div class="printout" style="position:absolute;top:75px;left:1em;width:95%;padding-bottom:75px;">');
	popup.document.writeln('<div style="height:75px;"></div>');
	if(cont.length > 0){
		var clipboard = new Element('div');
		var myCont = new Element('div', {
			'styles':{
			'float':'left',
			'clear':'left',
//			'backgroundColor':'#f4f4f4',
			'padding':'0 5 5 5',
//			'border':'1px solid #9f9f9f',
			'position':'absolute'
			}
		});
		var mySrc = null;
		var topspace = 0;
		cont.each(function(el){
			mySrc = el.getElement('div.scrollcontent');
			if(mySrc == null)
				mySrc = el.getElement('div.inner');
			myCont.setHTML(mySrc.innerHTML);
			myCont.setStyle('left', offset);
			myCont.setStyle('height', mySrc.getSize().scrollSize.y + 10);
			offset += mySrc.getSize().scrollSize.x;
			offset += 10;
			topspace = Math.max(mySrc.getSize().scrollSize.y + 10, topspace);
			myCont.getElements('script').each(function(el){el.remove();});
			clipboard.adopt(myCont.clone(true));
		});
/*
		var myCont;
		cont.each(function(el){
			myCont = el.clone(true);
			myCont.getElements('script').each(function(el){el.remove();});
			myCont.setStyles({'height':el.getSize().scrollSize.y, 'position':'static'});
			clipboard.adopt(myCont);
		});
 */
		popup.document.writeln(clipboard.innerHTML);
		popup.document.writeln('<div style="position:absolute;top:' + (topspace + 100) + 'px;color:#333; left:0px;">&copy; Sedus Stoll Aktiengesellschaft - Br&uuml;ckenstra&szlig;e 15 - D-79761 Waldshut - Tel. +49 (7751) 84-0 - Fax +49 (7751) 84-310 - sedus@sedus.de</div>');
	}
	else{
		var myCont = cont.clone(true);
		var scroller = cont.getElement('div.scrollcontent');
		if(scroller != null){
			var myHeight = scroller.getSize().scrollSize.y;
			var myScroller = myCont.getElement('div.scrollcontent');
			myScroller.setStyle('height', myHeight + 'px');
			$(myScroller.parentNode).setStyle('height', myHeight + 'px');
			$(myScroller.parentNode.parentNode).setStyle('height', myHeight + 'px');
			topspace = myHeight + scroller.getCoordinates().top;
		}
		else{
			topspace = cont.getSize().scrollSize.y;
		}
//		myCont.getElements('div.scrollcontent').
		myCont.getElements('script').each(function(el){el.remove();});
		if(cont.id.contains('references')){
			var refs = new Element('table');
			var tCont = new Element('div');
			myCont.getElements('div.ref_box').each(function(el){
				var row = new Element('tr', {
					'styles':{
						'height':120
					}
				});
				var cells = el.getChildren();
				var left = new Element('td', {
					'styles':{
						'height':114,
						'width':171,
						'border':'6px solid #fff'
					}
				});
				left.setHTML(cells[0].innerHTML);
				var right = new Element('td', {
					'styles':{
						'height':114,
						'width':297,
						'border':'6px solid #fff',
						'background-color':'#f4f4f4'
					}
				});
				right.setHTML(cells[1].innerHTML);
				row.adopt([left, right]);
				refs.adopt(row);
			});
			tCont.adopt(refs);
			popup.document.write(tCont.innerHTML);
//			if(navigator.appName.contains('Microsoft')&& !navigator.appVersion.contains('6.0')){
//				topspace += 115;
//			}
	popup.document.writeln('<p><small>&copy; Sedus Stoll Aktiengesellschaft - Br&uuml;ckenstra&szlig;e 15 - D-79761 Waldshut - Tel. +49 (7751) 84-0 - Fax +49 (7751) 84-310 - sedus@sedus.de</small></p>');
		}
		else{
			if(cont.id.contains('downloadsresult')){
				var tCont = new Element('div');
				cont.getElements('p.proddllink').each(function(elem){
					tCont.adopt(elem.clone(true).setStyles({'padding':'1em', 'margin':0}));
				});
				popup.document.write(tCont.innerHTML);
			}
			else{
				popup.document.write(myCont.innerHTML);
				popup.document.writeln('<div style="position:absolute;top:' + (topspace + 100) + 'px;color:#333; left:0px;">&copy; Sedus Stoll Aktiengesellschaft - Br&uuml;ckenstra&szlig;e 15 - D-79761 Waldshut - Tel. +49 (7751) 84-0 - Fax +49 (7751) 84-310 - sedus@sedus.de</div>');
			}
		}
	}
//	popup.document.writeln('</div>');
	popup.document.writeln('</body>');
	popup.document.writeln('</html>');
	popup.document.close();
	popup.print();
}
function getMSFreePos(x, y, idx){
	var iy = Math.floor(idx/7);
	var ix = idx - (iy * 7);
	var fi = true;
	for(var k = 0; k < x; k++){
		for(var l = 0; l < y; l++){
			if((ix + k) > 6 || (sPos[ix + k].length > 0 && sPos[ix + k][iy + l] === true)){
				fi = false;
			}
		}
	}
	if(fi === true){
		var res = {'x':ix + k - 1, 'y':iy + l - 1};
		return res;
	}
	else{
		return getMSFreePos(x, y, idx + 1);
	}
}

/*
Function: showMySedus
	grow little "My Sedus" box to full size and display saved saveables
*/
function showMySedus(){
//	sPos = [[], [], [], [], [], [], []];
	var myOrigin = $('se_de_teaser_my-sedus');
	var myCont = myOrigin.clone(false);
	myCont.id = 'my-sedus-large';
	var myFx = myCont.effects({duration: 250});
	myCont.setStyles({
		'background-color': myOrigin.getElement('div.inner').getStyle('background-color'),
		'z-index': 99,
		'opacity': 0
	});
	var flash = $('flash');
	$ES('select').setStyle('visibility', 'hidden');
	if(flash != null)
		flash.setStyle('display', 'none');
	myCont.setStyles(myOrigin.getCoordinates());
	$$('body').adopt(myCont);
	myOrigin.effects({duration:250}).start({'opacity':0});
	var myBoxCont = new Element('div', {
		'styles':{
			'position':'absolute',
			'top':gridSize,
			'left':0,
			'background-color':'#FF8542'
		}
	});
	myCont.adopt(myBoxCont);
	var textCont = new Element('div', {
		'class':'head-text',
		'styles':{
			'position':'absolute',
			'top':20,
			'left':0,
			'width':'100%',
			'height':gridSize - 26
		}
	});
	textCont.setHTML(mySedusText);
	var _doBtn = new Element('div', {
		'class':'drpoutbtn',
		'styles':{
			'position':'absolute',
			'bottom':0,
			'right':0,
			'height':28,
			'width':114,
			'display':'none'
		}
	});
	var _upBtn = _doBtn.clone();
	_doBtn.setHTML('<a href="#" style="color:#fff;text-align:right;" rel="static">' + sedusStrings.more + '&nbsp;<img width="12" height="7" src="' + imgPath + 'pfeil-aufklappen_o.gif" /></a>');
	_upBtn.setHTML('<a href="#" style="color:#fff;text-align:right;" rel="static">' + sedusStrings.back + '&nbsp;<img width="12" height="7" src="' + imgPath + 'pfeil-zuklappen_o.gif" /></a>');
	_doBtn.addEvents({
		'click':function(){
			myCont.effects().start({'height':myCont.getElement('div').getSize().scrollSize.y + 165});
			this.setStyle('display','none');
			_upBtn.setStyle('display','block');
		}
	});
	_upBtn.addEvents({
		'click':function(){
			myCont.effects().start({'height':594});
			this.setStyle('display','none');
			_doBtn.setStyle('display','block');
		}
	});
	myFx.start({'opacity':0.95}).chain(function(){
		var dragger = new Element('div', {
			'class':'dragger',
			'styles':{
				'cursor':'pointer',
				'background':'url(\'/se/global/layout/img/header-my-sedus-large.png\') left top no-repeat'
			}
		});
		myCont.adopt(dragger);
		dragger.addEvent('click', function(e){
			new Event(e).stop();
			var mC = myOrigin.getCoordinates();
			myCont.effects().start({
				'width':mC.width - 6,
				'height':mC.height - 6,
				'top':mC.top,
				'left':mC.left
			}).chain(function(){
				this.start({
					'opacity':0
				});
				myOrigin.effects().start({'opacity':1});
				var flash = $('flash');
	$ES('select').setStyle('visibility', 'visible');
				if(flash != null)
					flash.setStyle('display', 'block');
				}).chain(function(){myCont.remove();});
		});
		myCont.adopt(textCont);
		this.start({
			'top':myPage.getCoordinates().top,
			'left':gridSize + myPage.getCoordinates().left,
			'width':gridSize * 7 - 6 + 'px',
			'height':gridSize * 5 - 6 + 'px'
		});
	}).chain(function(){
		var closeBtn = new Element('div', {
			'styles':{
				'position':'absolute',
				'top':97,
				'left':1,
				'cursor':'pointer',
//				'opacity':0.6,
				'z-index':6
			}
		});
		textCont.adopt([_doBtn, _upBtn]);
		closeBtn.setHTML('<img width="15" height="14" alt="" src="' + imgPath + 'schliessen.gif' + '" />');
		sedusSaved.keys().each(function(elid){
			var clipper = new Element('div');
			new Ajax(idToURL(elid), {
				method: 'get',
				update: clipper,
				onFailure:function(){
					sedusSaved.remove(elid);
				},
				onComplete: function(){
					clipper.getChildren().each(function(el){
					if(el.tagName.toLowerCase() == 'div'){
						el.id += '--sedus';
						el.setStyles({
							'display':'block',
							'visibility':'visible',
							'margin':'0',
							'opacity':1,
							'position':'absolute',
							'top':0,
							'left':0
//							'float':'left'
						});
						el.getElements('a[display=block]').each(function(lnk){lnk.setStyle('display', 'inline');});
						for(var i = 0; i <= 25; i++){
							el.removeClass('posx'+i);
							el.removeClass('posy'+i);
						}
						el.getElements('.overlay').each(function(lnk){
							if(lnk.tagName.toLowerCase() == 'a'){
								lnk.onclick = OL_bind;
							}
							else{
								lnk.onsubmit = OL_bind_form;
							}
						});
						if(el.hasClass('product_box')){
							var img = el.getElement('img');
//							el.getElement('div.product_text').setStyle('width', img.getAttribute('width'));
//							el.getElement('p.product_name').setStyle('width', '100%');
//							el.setStyles({'height':'114px','width':img.getAttribute('width'), 'overflowY':'hidden'});
//							el.getElement('div.product_text').setStyle('width', img.getAttribute('width'));
							if(img != null){
								if(navigator.appName.contains('Microsoft') && navigator.appVersion.contains('6.0')){
									el.setStyles({'height':'114px','width':img.getAttribute('width'), 'overflowY':'hidden'});
//									el.getElement('div.product_text').setStyle('width', el.getStyle('width'));
								}
//								else{
//									el.getElement('p.product_name').setStyle('width', img.getAttribute('width'));
//								}
							}
						}
						myBoxCont.adopt(el);
//						var eGS = el.getGridSize();
//						var eP = getMSFreePos(eGS.width, eGS.height, 0);
if(navigator.appName.contains('Microsoft') && navigator.appVersion.contains('6.0')){
						el.setStyles({
							'width':Math.round(el.getCoordinates().width/gridSize) * gridSize - 6,
							'height':Math.round(el.getCoordinates().height/gridSize) * gridSize - 6,
							'opacity':0
						});
}
else{
						el.setStyles({
							'width':Math.round(el.getCoordinates().width/gridSize) * gridSize - (2 * el.getStyle('border-width')) - 6,
							'height':Math.round(el.getCoordinates().height/gridSize) * gridSize - (2 * el.getStyle('border-width')) - 6,
							'opacity':0
						});
}
//						el.getElements('div.scrollable').each(function(c){c.mkScrollable();});
//						if(el.hasClass('scrollable'))
//							el.mkScrollable();
						var _btn = closeBtn.clone(true);
						_btn.addEvents({
							'click':function(e){
								new Event(e).stop();
								sedusSaved.remove(el.id.split('--')[0]);
								var elem = $(el.id.split('--')[0]);
								if(elem != null){
									elem.getElement('div.saveBtn').setHTML('<img src="' + imgPath + 'diskette.gif" alt="speichern" />')
								}
								el.disappear();
							}
						});
						if(el.getSize().size.y > 130)
							_btn.setStyle('top', 217);
						if(parseInt(el.getStyle('borderTopWidth'))>0){
							_btn.setStyle('top', parseInt(_btn.getStyle('top')) - (2 * parseInt(el.getStyle('borderTopWidth'))));
						}
						el.adopt(_btn);
						var myBCC = myBoxCont.getCoordinates();
						var myElemCoords = el.getCoordinates();
//						console.debug(myElemCoords);
						var myOuter = new Element('div', {
							'styles':{
								'float':'left',
								'width':Math.round(myElemCoords.width/gridSize) * gridSize - 6 + 'px',
								'height':Math.round(myElemCoords.height/gridSize) * gridSize - 6 + 'px',
								'overflow':'hidden'
							}
						});
						myBoxCont.adopt(myOuter);
						var myOuterCoords = myOuter.getCoordinates();
						var myOuterC = {
							'top':Math.round((myOuterCoords.top - myBCC.top)/gridSize) * gridSize + 'px',
							'left':Math.round((myOuterCoords.left - myBCC.left)/gridSize) * gridSize + 'px',
							'opacity':1
						};
//						console.debug(myOuterC);
//						alert(myOuterC.top + '  ' + myOuterC.left + "\n" + myElemCoords.top + '  ' + myElemCoords.left);
//						el.setStyles(myOuterC);
//						myOuter.remove();
						el.effects({
							duration:500 + Math.round(Math.random() * 1000),
							onComplete:function(){
								if(myCont.getElement('div').getSize().scrollSize.y > 490){
									_doBtn.setStyle('display','block');
								}
							}
						}).start({
//							'left':[1000 + Math.round(Math.random() * 1000), eP.x * gridSize],
//							'top':[1000 + Math.round(Math.random() * 1000), eP.y * gridSize],
							'left':[1000 + Math.round(Math.random() * 1000), myOuterC.left],
							'top':[1000 + Math.round(Math.random() * 1000), myOuterC.top],
							'opacity':1
						});

//						if(!sPos[eP.x]){
//							sPos[eP.x] = [];
//						}
//						if(el.getCoordinates().top + el.getCoordinates().height > 620)
//						for(var i = 0; i < eGS.width;i++){
//							for(var j = 0; j < eGS.height;j++){
//								sPos[eP.x + i][eP.y + j] = true;
//							}
//						}
					}
					});
				}
			}).request();
		});
	});
}

function bindLink(e){
	var e = new Event(e);
	e.preventDefault();
	this.blur();
	fetchIndex(this.href);
	this.onclick = bindLink;
	return false;
}

function bindAJAXLink(e){
/* 	e = new Event(e);
	e.preventDefault();
	this.blur();
	var myClipper = new Element('div');
	var myClipper2 = new Element('div');
	new Ajax(this.href + '?index', {update:myClipper, onComplete:function(){
		myClipper.getElements('div').each(function(el){
			if(el.id && !el.id.contains('picture')){
				new Ajax(idToURL(el.id), {update:myClipper2, evalScripts:true, onComplete:function(){
					$$('body').getElements('div.content div.box').each(function(elem){if(!elem.id || (!elem.id.contains('my-sedus') && !elem.id.contains('sec-navi') && !elem.id.contains('meta-navi')))elem.disappear();});
					myClipper2.getElements('div.content').each(function(myContent){
						if($$('body').getElement('div[id='+myContent.id+']') == null)
							$('myPage').adopt(myContent);
						myContent.handleProperties();
					});
				}}).request();
			}
			if(el.id && el.id.contains('picture')){
				$('myPage').adopt(el);
				el.handleProperties();
			}
		});
	}}).request();
	this.onclick = bindAJAXLink;
	return false;
 */
}

/*
Function: addScrollToggler
	make element grow by providung link to <dropout()> and <dropin()>

Arguments:
	myCont - element to use
 */
function addScrollToggler(myCont){
//	var myOInner = myCont.getElement('div.inner');
//	myOInner.setStyle('height','auto');
	var myGS = myCont.getGridSize();
	var myS = myCont.getSize();
	var myPage = $('myPage');
	if((myGS.top + myGS.height) <= 4 && ((myS.scrollSize.y - 10) > myS.size.y)){
		var tDiv = new Element('div', {
			'id':'droptoggler',
			'class':'sizex1 sizey1 content posx' + (myGS.left + myGS.width - 1) + ' posy' + (myGS.top + myGS.height)
		});
		var myInner = new Element('div', {
			'class':'drpoutbtn',
			'styles':{
				'width':114
			}

		});
		var myLink = new Element('a', {
			'href':'#',
			'events':{
				'click':function(e){
					e = new Event(e);
					e.preventDefault();
					myCont.dropout();
				}
			}
		});
		myLink.setHTML(sedusStrings.more + '&nbsp;<img align="baseline" width="12" height="7" name="aufklappen" src="' + imgPath + 'pfeil-aufklappen.png" />');
		myPage.adopt(tDiv);
		tDiv.adopt(myInner);
		myInner.adopt(myLink);
		var tGS = tDiv.getGridSize();
		var bContId = posMatrix[tGS.left][tGS.top];
		if(bContId != null){
			$(document.getElementById(bContId)).setAttribute('style', '');
		}
	}
}

/*
Section: Init Functions
*/

/*
Function: initDnD
	initialize the drag and drop functions
*/
function initDnD(){
	drag_overlay = new Element('div', {
		'class': 'drag_overlay'
	});
	drag_overlay.setHTML('<img width="500" height="20" src="' + imgPath + 'blank.gif" alt="Drag" />');
	dragger = new Element('div', {
		'class': 'dragger'
	});
	dragger_left = new Element('div', {
		'class': 'dragger_left'
	});
	dragger_left.adopt(new Asset.image(imgPath + 'header_left.png', {'alt': ''}));
	dragger_right = new Element('div', {
		'class': 'dragger_right'
	});
	dragger_right.adopt(new Asset.image(imgPath + 'header_right.png', {'alt': ''}));
	dragger.adopt(dragger_left);
	dragger.adopt(dragger_right);
}

/*
Function: initLinks
	initialize the links and make function calls, will not touch links with rel="static"

Arguments:
	cont - optional: container to look for links in
*/
function initLinks(cont){
/*  myFrame = $('_fetcher');
	if(cont == undefined)
		cont = myPage;
	$ES('a[href]', cont).each(function(el){
		if((!el.rel || el.rel != 'static') && el.href != '#'){
			el.onclick = bindLink;
		}
	});*/
//	fetchIndex(window.location.href);
	$ES('a[href]', cont).each(function(el){
		if((!el.rel || el.rel != 'static') && el.href != '#'){
			el.onclick = bindAJAXLink;
		}
	});
}

/*
Function initPos
	init element position system, take care of special handling for tag cloud container (<tcCont>)
*/
function initPos(){
	$('ZMax_logo').blockPos();
	if(tcCont != null){
		var tcGS = tcCont.getGridSize();
		var tcC = tcCont.getCoordinates();
		var add = 0;
		tcCont.getElements('div.expand').each(function(el){
			add = Math.max(add, el.getSize().scrollSize.y);
		});
		blockPos({
			'top':tcGS.top,
			'width':tcGS.width,
			'left':tcGS.left,
			'height':Math.ceil((tcC.height + add)/gridSize)
		}, 'tc');
	}
	myPage.getChildren().each(function(el){
		if(el.hasClass('box') || el.hasClass('content'))// || el.hasClass('tagcloud'))
			el.setPos();
	});
}

/*
Function: initMain
	fetches main skel, injects it into top page container and calls <initPos()> and <initDnD()>
*/
function initMain(){

//	alert(navigator.appVersion + "\n" + navigator.appCodeName);
	dragHelper = $('drag_helper');
	myPage = $('myPage');
//	var do = new Asset.images();
	initDnD();
	myPage.setStyle('top', pageOffset.top);
	$$('div').each(function(el){
		el.handleProperties();
	});
	tcCont = $('tc');
	$$('a.overlay, form.overlay').each(function(el){
		if(el.tagName.toLowerCase() == 'a'){sedusStrings.back
			el.onclick = OL_bind;
		}
		else{
			el.onsubmit = OL_bind_form;
		}
	});
//	initLinks();
	initPos();
//	$('_fetcher').src = location.href + '?index=123456789'
//	$('fetchform').action = location.href;
//	$('index_field').value = '123456789';
//	$('fetchform').submit();

/* Tracking Aufrufe */
/* Hier die Kommentare wieder entfernen, um das Tracking zu aktivieren. */
//dcsVar();
//dcsMeta();
//dcsFunc("dcsAdv");
//dcsTag();


}

